package com.controller;

import com.base.BaseController;
import com.base.BasePageRes;

import com.req.RssPageReq;
import com.req.RssReq;
import com.res.RssRes;
import com.res.UserRes;
import com.service.RssService;
import com.util.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rss")
@Api(tags = "订阅")
public class RssController extends BaseController {
    @Autowired
    private RssService rssService;
    @PostMapping("/save")
    @ApiOperation("订阅的增删改查")
    public R<RssRes> saveRss(@RequestBody RssReq req){
        UserRes user = this.getUser();
        req.setUserId(user.getId());
        return R.ok(rssService.saveRss(req));
    }
    @PostMapping("/queryPage")
    @ApiOperation("订阅分页查询")
    public R<BasePageRes> queryPage(@RequestBody RssPageReq pageReq){
        UserRes user = this.getUser();
        pageReq.setUserId(user.getId());
        return R.ok(rssService.queryPage(pageReq));
    }
//    @PostMapping("/detailPage")
    @ApiOperation("此接口无效，改用 channelcontroller下的详情接口，订阅详情分页查询")
    public R<BasePageRes> detailPage(@RequestBody RssPageReq pageReq){

        return R.ok(rssService.detailPage(pageReq));
    }

}
